package edu.pku.sei.autounit.reflect;

import java.util.ArrayList;
import java.util.List;

public abstract class AbstractContextType extends AbstractType implements Context{

	protected TypeParameter [] typeParameters;
	
	
	final public Type[] getContexts() {
		List<Type> list = new ArrayList<Type>();
		for(TypeParameter tpyeParameter : typeParameters){
			if(tpyeParameter!=null&&tpyeParameter.getContext()!= null)
				list.add(tpyeParameter.getContext());
		}
		return list.toArray(new Type[list.size()]);
	}
	
	final public TypeParameter getTypeParameter(String name){
		for(TypeParameter t:typeParameters){
			if(t!=null&&t.getName().equals(name))
				return t;
		}
		return null;
	}
}
